local ClientOHOH = _G.ClientOHOH;

local M = ClientOHOH.class.new(script, ClientOHOH.files.BaseObject())
local CallBackManager = ClientOHOH.load.CallBackManager();
local ConnectClass=_G.CommonOHOH.load.Connect();

local instStr={
    BestEquip="ctrl.Equip.equipBest",--装备最佳按钮
    MakeAll ="ctrl.Equip.makeAll",--购买好友装备槽位
    UnEquipAll ="ctrl.Equip.unEquipAll",--卸载所有
}

function M.new(...)
	return M(...);
end;


function M.ctor(self,ctrl)

    M.super.ctor(self);

    self.bestEquipEvent=ConnectClass.new();
    self.UnEquipAllEvent=ConnectClass.new();
    self.buyEquipSlotslEvent=ConnectClass.new();

    self.ctrl=ctrl
    self.ui=ctrl:InitUiInst2(ctrl.main_inst,instStr)
    

    CallBackManager:AddRbxConnect(self,self.ui.BestEquip.Activated, function()
        self.ctrl.BestEquipEvent:Action()
	end);

    CallBackManager:AddRbxConnect(self,self.ui.UnEquipAll.Activated, function()
        self.ctrl.UnEquipAllEvent:Action()
	end);

    CallBackManager:AddRbxConnect(self,self.ui.MakeAll.Activated, function()
        self.ctrl.MergeAllEvent:Action()
	end);
  
    self:Hide()
	
end;


function M.dtor(self)
	M.super.dtor(self);
end;

function M.IsShowing(self)
    return self.isShow
end


function M.Show(self)
    self.ui.BestEquip.Visible=true
    self.ui.UnEquipAll.Visible=true
    self.ui.MakeAll.Visible=true
    self.isShow=true
end


function M.Hide(self,cell)
    self.ui.BestEquip.Visible=false
    self.ui.UnEquipAll.Visible=false
    self.ui.MakeAll.Visible=false
    self.isShow=nil

    if  self.ActiveCell then
        self.ActiveCell:NoActive()
        self.ActiveCell=nil
    end

    self:Big()
end

function M.Change(self,cell)
    if self.ActiveCell==cell then
        
        self:CancelSelect(cell)
    else
        self:Select(cell)
    end
end

function M.CancelSelect(self)

    if self.ActiveDeleteCon then
        self.ActiveDeleteCon:Disconnect()
        self.ActiveDeleteCon=nil
    end
    self:Big()
    if self.ActiveCell then
        self.ActiveCell:NoActive()
    end
    self.ActiveCell=nil
    self.ctrl:GetDetails():Hide()
end

function M.Select(self,cell)
    self:Small()
    if self.ActiveCell then
        self.ActiveCell:NoActive()
    end
    self.ActiveCell=cell
    cell:Active()
    self.ctrl:GetDetails():Show(cell)
    self.ActiveDeleteCon=self.ActiveCell.DeleteEvent:Connect(function()
        self.ActiveCell=nil
        self:CancelSelect()
    end)
end


function M.Big(self)
    self.ctrl:GetList():Big()
end


function M.Small(self)
    self.ctrl:GetList():Small()

end

return M